package org.apache.ibatis.common.exceptions;

import org.apache.ibatis.sql.executor.ErrorContext;

/**
 * @Name ExceptionFactory
 * @Description: 异常工厂类
 * @Version v1.0.0
 * @Author: lichao
 * @Date: 2024-04-24 16:08:42
 **/
public class ExceptionFactory {

    private ExceptionFactory() {
    }

    /**
     * 生成一个（包含上级异常上下文的）运行时异常
     *
     * @param msg 上级异常（上下文，链）消息
     * @param e   上级异常
     * @return java.lang.RuntimeException 结果
     * @version v1.0.0
     * @author lichao
     * @date 2024-04-24 16:10:32
     */
    public static RuntimeException wrapException(String msg, Exception e) {
        return new PersistenceException(ErrorContext.instance().message(msg).cause(e).toString(), e);
    }

}

